<%@page import="org.stwy.pro.asset.AssetEntity"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<c:set var="serviceurl" value="${ctx}/pro/asset" />
<html>
<head>
</head>
<body>
	<!-- 引入变更模态框  -->
	<%@include file="asset_change.jsp"%>
	
	<div class="container-fluid rap-select-container" id="rap-container-list">
		<div class="rap-page-area" id="rap-page-area-list">
			
			<div class="col-md-12 col-sm-12 rap-layout-main">
				<div class="row rap-toolbar">
				<shiro:hasPermission name="stwy:pro:asset:canNotRent:setnull">
					<button id="rap-btn-selfuse">
						<i class=""></i> 空置
					</button>
				</shiro:hasPermission>
					<!-- <button id="rap-btn-canNotRent">
						<i class=""></i> 设为不可出租
					</button> -->
					<button id="rap-btn-refresh">
						<i class="fa fa-refresh"></i> 刷新
					</button>
					<button id="rap-btn-export">
						<i class="fa fa-file-excel-o"></i> 导出
					</button>
				</div>
				<div class="row rap-searchbar" >
					<form id="rap-form-query" class="form-inline">
						<input type='hidden' name='search_EQ_status' value='1'>
						<input type='hidden' name='search_IN_groupOne' class="stwy_search_groupOne">
						<input type='hidden' name='search_IN_groupTwo' class="stwy_search_groupTwo">
						<input type='hidden' name='search_EQ_assetState' value='<%=AssetEntity.ASSET_STATUS_CANNOTRENT%>'><!-- 查询自用的 -->
						<input type='hidden' name='orderby' value='property.uuid'>
						<div class="form-group">
							<label for="search_LIKE_theName">资产名称</label> 
							<input type="text" class="form-control" id="search_LIKE_theName"
								name="search_LIKE_theName" autocomplete="on">
						</div>
						<div class="form-group">
							<label for="search_EQ_region">区域</label> 
							<select class="rap-input-enumdata" name="search_EQ_region" data-enum-group="stwy_region"></select>
						</div>
						<div class="form-group">
							<label for="search_EQ_usefor">用途</label> 
							<select class="rap-input-enumdata" name="search_EQ_usefor" data-enum-group="stwy_usefor"></select>
						</div>
						<div class="form-group">
							<label for="search_EQ_groupOne">一级组别</label> 
							<select class="rap-input-enumdata" name="search_EQ_groupOne" data-enum-group="stwy_groupOne"></select>
						</div>
						<div class="form-group">
							<label for="search_EQ_groupTwo">二级组别</label> 
							<select class="rap-input-enumdata" name="search_EQ_groupTwo" data-enum-group="stwy_groupTwo"></select>
						</div>
						
						<div class="form-group rap-searchbar-btn">
							<button type="button" id="rap-btn-quickquery">查询</button>
							<button type="reset">清空</button>
						</div>
					</form>
				</div>
				<div class="row">
			<table id="rap-table-list" class="rap-table rap-table-list">
				<thead>
					<tr>
						<th><label><input type="checkbox"
								class="rap-table-checkbox group-checkable"
								data-set="#rap-table-list .checkboxes" /><span class="lbl"></span></label>
						</th>
						<th>所属物业</th>
						<th>资产名称</th>
						<th>物业总面积(m²)</th>
						<th>资产面积(m²)</th>
						<th>区域</th>
						<th>用途</th>
						<th>不可出租日期</th>
						<th>不可出租类型</th>
						<th>不可出租原因</th>
					</tr>
				</thead>
				<tbody>
				</tbody>
			</table>
				</div>
			</div>
		</div>
	</div>
	<!-- 公用脚本 注意一下onRefresh()方法，在刷新的时候是选中服务器分页还是非服务器分页-->
	<%@include file="/WEB-INF/views/common/commonscript.jsp"%>
	
	<%@include file="asset_view_script.jsp"%>
	
	<script type="text/javascript">
		//是否服务器分页
		var _isServerPage = true;
		//表格列定义
		var _tableCols = 	[{
			data : "uuid",
			sortable : false,
			className : "center",
			width : "30",
			render : RapDataTableUtils.renderCheckCol
		},
		{
			data : null,
			width : "120",
			render : function(data, type, full) {
				var content = data.property==null?"":data.property.theName;
				return RapDataTableUtils.renderStrByLength(content,24);
			},
			sortable : false
		},
		{
			data : 'theName',
			width : "120",
			render : function(data, type, full) {
				//return RapDataTableUtils.renderStrByLength(data,24);
				return "<a href='#' id='assetInfo' onclick='onViewAsset(this,\""+full.uuid+"\");'>"+data+"</a>";
			},
			sortable : true
		},
		{
			data : null,
			width : "120",
			className :"rap-td-number",
			render:function (data, type, full){
				var content = data.property==null?"":data.property.totalArea;
				return milliFormat(content);
			},
			sortable : false
		},
		{
			data : 'area',
			width : "120",
			className :"rap-td-number",
			render:milliFormat,
			sortable : true
		},
		{
			data : 'region',
			width : "120",
			sortable : true,
			render : function(data, type, full) {
				return RapDataUtils.getEnumName("stwy_region", data);
			}
		},
		{
			data : 'usefor',
			width : "120",
			sortable : true,
			render : function(data, type, full) {
				return RapDataUtils.getEnumName("stwy_usefor", data);
			}
		},
		{
			data : 'recordDate',
			width : "120",
			sortable : true
		},
		{
			data : 'canNotRentType',
			width : "120",
			sortable : true,
			render : function(data, type, full) {
				return RapDataUtils.getEnumName("stwy_canNotRentType", data);
			}
		},
		{
			data : 'reason',
			width : "120",
			sortable : false,
			render : function(data, type, full) {
				return RapDataTableUtils.renderStrByLength(data,24);
			}
		}];
		RapDataTableUtils.setActions=function(nRow, aData, iDataIndex){
			/* $('#assetInfo', nRow).click(function() {
				onView(this,aData);
			}); */
		}
		
		//绑定除了默认事件外的其他事件
		function bindOtherAction(){
			$("#rap-btn-selfuse").bind("click",function(){
				changeAssetState(state_cannotrent,state_null,"资产变更为空置");
			});
			/* $("#rap-btn-canNotRent").bind("click",function(){
				changeAssetState(state_null,state_cannotrent,"资产变更为不可出租");
			}); */
		}
		$(document).ready(function() {
			bindDefaultActions();
			bindOtherAction();
			_queryData = $("#rap-form-query").serializeArray();
			if(_isServerPage){
				//服务器分页
				serverPage();	
			}else{
				//非服务器分页
				_tableList = $('#rap-table-list').DataTable({
					"columns" : _tableCols,
					"createdRow" : RapDataTableUtils.setActions,
					"order": [] 
				});
				loadList();		
			}
			RapDataTableUtils.setCheckCol(_tableList);
		});
	</script>
</body>
</html>
